package com.zhihaoliang.baseframe.db.entity;

import androidx.room.Entity;
import androidx.room.ForeignKey;
import androidx.room.Ignore;
import androidx.room.Index;
import androidx.room.PrimaryKey;


import com.zhihaoliang.baseframe.model.Comment;

import java.util.Date;

/**
 * 创建日期：2020-02-24
 * 描述:商品的评论的表
 * 作者:支豪亮
 */
@Entity(tableName = "comments", foreignKeys = {
        @ForeignKey(entity = ProductEntity.class,
                parentColumns = "id",
                childColumns = "productId",
                onDelete = ForeignKey.CASCADE)},
        indices = {@Index(value = "productId")})
public class CommentEntity implements Comment {
    @PrimaryKey(autoGenerate = true)
    private int id;

    private int productId;

    private String text;

    private Date postAt;

    @Override
    public int getId() {
        return id;
    }

    @Override
    public int getProductId() {
        return productId;
    }

    @Override
    public String text() {
        return text;
    }

    @Override
    public Date getPostAt() {
        return postAt;
    }

    public void setId(int id) {
        this.id = id;
    }

    public void setProductId(int productId) {
        this.productId = productId;
    }

    public void setText(String text) {
        this.text = text;
    }

    public void setPostAt(Date postAt) {
        this.postAt = postAt;
    }

    @Ignore
    public CommentEntity(int id, int productId, String text, Date postAt) {
        this.id = id;
        this.productId = productId;
        this.text = text;
        this.postAt = postAt;
    }

    public CommentEntity() {
    }
}
